package demo6;


class Phones {
    public void call() {
        System.out.println("电话");
    }
}

class IPhone extends Phones{
    @Override
    public void call() {
        System.out.println("IPhone 电话");
    }
}

class APhone extends Phones{
    @Override
    public void call() {
        System.out.println("APhone 电话");
    }
}

class WPhone extends Phones{
    @Override
    public void call() {
        System.out.println("Windows Phone 电话");
    }
}
public class Test {
    public static void main(String[] args) {
        Phones[] phones = new Phones[]{new IPhone(),new WPhone(),new APhone()};
        for (int i = 0; i < phones.length; i++) {
            call(phones[i]);
        }
    }
    public static void call(Phones ph) {
        if (ph instanceof Phones) {
            ph.call();
        }
    }
}
